IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_XML' AND xtype='FN') 
BEGIN
	DROP FUNCTION WEB_XML
END
GO

CREATE  function WEB_XML(@s varchar(8000))
returns varchar(8000)
as
begin
declare @res varchar(8000)
set @res = isnull(@s,'')
set @res = replace(@res,'&','&amp;')
set @res = replace(@res,'<','&lt;')  
set @res = replace(@res,'>','&gt;')

return @res
end